package com.me.test;

import java.util.Scanner;

/**
 * @author Li
 * @Date 2023/4/8 9:38
 */
public class Performance {
    public static void main(String[] args) {
        /**
         * 计算公司每个季度销售数量总和
         */
        int one = getNum("第一季度销量:");
        int two = getNum("第二季度销量:");
        int three = getNum("第三季度销量:");
        int all = getNum("优秀的标准:");
        int sum = getSum(one,two,three);
        System.out.println("销量总和:"+sum);
        judge(sum,all);

    }

    /**
     * 将所有季度销量和与输入的优秀标准进行比较
     * @param sum
     * @param all
     */
    private static void judge(int sum,int all) {
        if (sum>all){
            System.out.println("销量好");
        }else {
            System.out.println("销量未达标");
        }
    }

    /**
     * 键盘输入季度销量
     * @param tips
     * @return
     */
    private static int getNum(String  tips) {
        Scanner scanner= new Scanner(System.in);
        System.out.println(tips);
        int num = scanner.nextInt();
        return num;
    }

    /**
     * 将输入的销量放入一个数组，遍历数组并求和
     * @param arr
     * @return
     */
    private static int getSum(int...arr) {  //不定长数组
          int sum = 0;
          for (int i= 0; i<arr.length;i++){
              sum += arr[i];

          }
        return sum;
    }
}
